Skip to content

refactor: change from serialising a u64 to i64 - #3065

Merged
blackmwk merged 1 commit into
apache:mainfrom
JosephLenton:feat-avro-first-row-id-is-i64
Aug 28, 2026
Merged

refactor: change from serialising a u64 to i64#3065
blackmwk merged 1 commit into
apache:mainfrom
JosephLenton:feat-avro-first-row-id-is-i64

Conversation

@JosephLenton

@JosephLenton JosephLenton commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

This is a part of the upgrade to Avro 0.22. We currently serialise the manifest first_row_id as a u64, and this is incorrect and out of spec.

From the Iceberg spec:

This is relevant to the Avro 0.22 upgrade because:

I am making this change on it's own to help isolate changes (and to isolate discussion in case this is the wrong place, or changes elsewhere are needed).

What changes are included in this PR?

  • Change from serialising first_row_id as a u64 to an i64.

Are these changes tested?

  • Tests from main pass.
  • I've also made this change on the Avro 0.22 branch I have, and the latest version works with this change.

AI Disclosure

The code changes and this PR comment is all made by a human.

Claude was used to debug the issue, and as a search. This included in code, and in spec.

@dannycjones dannycjones left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed this too when reviewing some of the row lineage stuff! Thanks for the PR.

I think this change makes sense, although I think we should extend it to ManifestFile type too which should eliminate the TryInto calls.

@JosephLenton

Copy link
Copy Markdown
Contributor Author

@dannycjones I can do that, however the PR will expand into a lot of places. The ManifestWriter interacts with many things, and they end up needing updating again or try_into everywhere.

For what it's worth I have a draft PR here where I moved everything across: #3068 . If that is preferable, I can close this PR and open that for review.

@dannycjones

Copy link
Copy Markdown
Contributor

@dannycjones I can do that, however the PR will expand into a lot of places. The ManifestWriter interacts with many things, and they end up needing updating again or try_into everywhere.

For what it's worth I have a draft PR here where I moved everything across: #3068 . If that is preferable, I can close this PR and open that for review.

I think that's the right approach - to me, we just chose the wrong type here so we should move those things across.

@dannycjones

dannycjones commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

@blackmwk and/or @CTTY, please can you check this is the right direction? I don't want to lead us on a larger change that we shouldn't make.

I see that there's a few types even for V2 (ManifestFile::existing_rows_count) that are unsigned in Rust, but in the spec are presumably signed assuming that its referring to Java types.

I am proposing to move from u64 to i64, which loses the guarantee in the library that these are positive (which they always should be) however the signed equivalent more closely represents what's described in the spec and serialized to Avro.

@anoopj anoopj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code change looks correct for the Avro 0.22 fix.

One question: the in-memory models (ManifestFile.first_row_id and Snapshot.first_row_id ) are still u64, while the manifest-level first_row_id is already i64 and the spec defines it as a signed long.

Is keeping the model as u64 an intentional scope-limit for the Avro upgrade, or would it be cleaner to make the them i64 too so the whole path matches the spec and the manifest-level type?

Not blocking though.

@blackmwk blackmwk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @JosephLenton for this fix, and @dannycjones @anoopj for review! I think this is the right direction to go, the i64 in ser/de types are to maintain compatibility with languages without native 64bit integer implementation. We could still use unsigned integer for in memory structs unless we see some actual problems.

@blackmwk
blackmwk merged commit 76572cf into apache:main Aug 28, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants